package io.gbznt.modules.buss.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.gbznt.modules.buss.entity.BussSwitchEntity;
import io.gbznt.modules.buss.service.BussSwitchService;
import io.gbznt.common.utils.PageUtils;
import io.gbznt.common.utils.R;



/**
 * 
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2019-05-21 14:34:11
 */
@RestController
@RequestMapping("buss/bussswitch")
public class BussSwitchController {
    @Autowired
    private BussSwitchService bussSwitchService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("buss:bussswitch:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = bussSwitchService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("buss:bussswitch:info")
    public R info(@PathVariable("id") String id){
		BussSwitchEntity bussSwitch = bussSwitchService.getById(id);

        return R.ok().put("bussSwitch", bussSwitch);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("buss:bussswitch:save")
    public R save(@RequestBody BussSwitchEntity bussSwitch){
		bussSwitchService.save(bussSwitch);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("buss:bussswitch:update")
    public R update(@RequestBody BussSwitchEntity bussSwitch){
		bussSwitchService.updateById(bussSwitch);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("buss:bussswitch:delete")
    public R delete(@RequestBody String[] ids){
		bussSwitchService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
